<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Contractor Details</title>
<link href="UniversalStyleSheet.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function instructions_change()
{
e=document.getElementById("Emergency")
d=document.getElementById("During")
if (e.selectedIndex != -1 && d.selectedIndex != -1)
	{
	emer=e.options[e.selectedIndex].value
	dur=d.options[d.selectedIndex].value
	ci=document.getElementById("ContractorInstructions")
	theday="<%= request.QueryString("theday") %>"
	contractor="<%= request.QueryString("contractor") %>"
	ci.src="ContractorInstructions.asp?theday=" + theday + "&contractor=" + contractor + "&emergency=" + emer + "&during=" + dur
	}
}
</script>
<% 
contractor=request.QueryString("contractor")
theday=request.QueryString("theday")
if contractor<>"" then
	contractor=replace(contractor,"_"," ")
	dim rs,db
	set db=server.CreateObject("adodb.connection")
	set rs=server.CreateObject("adodb.recordset")
	
	filepath="c:\Alpha Page\Front End\AfterHours_be.mdb" 'server.MapPath("/afterhours/access/backend/afterhours_be.mdb")
	db.open ("provider=microsoft.jet.oledb.4.0;data source=" & filepath )
	sql="select * from contractors where [code]='" & contractor & "'"
	rs.open sql,db,1,2
	if rs.recordcount=0 then
		contractor_name="(Error finding contractor #" & contractor & ")"
		available=""
		contact=""
	else
		available=rs(theday & " time")
		contact=rs(theday & " contact")
		contractor_name=rs("name")
				
		'convert line-breaks to <br>
		if available<>"" then
			available=replace(available,chr(13),"<br/>")
		end if
		
		if contact<>"" then
			contact=replace(contact,chr(13),"<br/>")
		end if
	end if
	
	rs.close
	db.close
	set rs=nothing
	set db=nothing
else
	available=""
	contact=""
end if
%>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="25%" align="left" valign="top"><table width="200" height="187" border="0" cellpadding="0" cellspacing="1" bgcolor="#009900">
      <tr>
        <td height="37" colspan="2" bgcolor="#D2FFD2" class="ContractorDisplay"><%= contractor_name %></td>
      </tr>
      <tr>
        <td width="50" height="29" align="left" valign="top" bgcolor="#FFFFFF" class="ResultsAddress">Time<br />
          Available:</td>
        <td width="147" align="left" valign="top" bgcolor="#FFFFFF" class="ResultsAddress"><%= available %></td>
      </tr>
      <tr>
        <td height="19" align="left" valign="top" bgcolor="#FFFFFF" class="ResultsAddress">Contact:</td>
        <td align="left" valign="top" bgcolor="#FFFFFF" class="ResultsAddress"><%= contact %></td>
      </tr>
      <tr>
        <td height="19" colspan="2" align="left" valign="top" bgcolor="#D2FFD2" class="ResultsAddress">&nbsp;</td>
      </tr>
      <tr>
        <td rowspan="2" align="left" valign="top" bgcolor="#FFFFFF" class="ResultsAddress">Choose:</td>
        <td height="38" align="left" valign="top" bgcolor="#FFFFFF" class="ResultsAddress"><select name="Emergency" size="2" id="Emergency" style="background-color:#FFFF99" onchange="javascript: instructions_change()">
            <option value="Emergency">Emergency</option>
            <option value="NonEmergency">Non-Emergency</option>
          </select>        
		  </td>
      </tr>
      <tr>
        <td align="left" valign="top" bgcolor="#FFFFFF" class="ResultsAddress">
		<select name="During" size="2" id="During" style="background-color:#FFFF99" onchange="javascript: instructions_change()">
			<% if lcase(contractor)="no on call" then
					op1="Contractors Available"
					op2="No Contractors"
				else
					op1="During Availability"
					op2="After Availability"
				end if
			%>
          	<option value="During"><%= op1 %></option>
          	<option value="After"><%= op2 %></option>
        </select>        
		</td>
      </tr>
    </table>	
	</td>
    <td width="75%" align="center" valign="top">
	<iframe src="ContractorInstructions.asp" name="ContractorInstructions" id="ContractorInstructions" frameborder="0" height="280" width="335" scrolling="auto"></iframe>
	</td>
  </tr>
</table>
</body>

</html>
